<template>
  <el-config-provider :locale="locale">
    <router-view />
  </el-config-provider>
</template>

<script>
import zhCn from 'element-plus/lib/locale/lang/zh-cn'
export default {
  data() {
    return {
      locale: zhCn, //分页中文化
    }
  },
  created() {
    if (sessionStorage.getItem('store')) {
      this.$store.replaceState(
        Object.assign(
          this.$store.state,
          JSON.parse(sessionStorage.getItem("store"))
        )
      );
      // Object.assign(this.$store.state.userInfo,JSON.parse(sessionStorage.getItem("store")).userInfo)
      sessionStorage.clear()
    }
    window.addEventListener('beforeunload', () => {
      console.log('beforeunload');
      sessionStorage.setItem('store', JSON.stringify(this.$store.state))
    })
  },
}
</script>

<style lang="less">
body {
  margin: 0px;
  padding: 0px;
  overflow: hidden;
}
</style>